package com.hbird.utils.db;

import java.io.Serializable;
import java.util.Date;

/**
 * 查询基类
 * 
 * @author zyh
 * @description
 */
public class BaseQuery implements Serializable{
	public enum OrderBy {
		DESC, ASC
	}

	protected int pageIndex;
	protected int pageSize;
	protected int pageTotal;
	protected int recordStart;
	protected int recordEnd;
	protected int recordTotal;
	protected Date timeStart;
	protected Date timeEnd;

	public void calPage(int totalRow) {
		this.recordTotal = totalRow;
		if ((totalRow != 0) && (totalRow % this.pageSize == 0)) {
			this.pageTotal = totalRow / this.pageSize;
		} else {
			this.pageTotal = totalRow / this.pageSize + 1;
		}

		if (totalRow == 0) {
			this.recordStart = 0;
		} else {
			this.recordStart = (this.pageIndex - 1) * this.pageSize;
		}

		this.recordEnd = this.pageSize;
	}

	public int getPageIndex() {
		return pageIndex;
	}

	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getPageTotal() {
		return pageTotal;
	}

	public void setPageTotal(int pageTotal) {
		this.pageTotal = pageTotal;
	}

	public int getRecordStart() {
		return recordStart;
	}

	public void setRecordStart(int recordStart) {
		this.recordStart = recordStart;
	}

	public int getRecordEnd() {
		return recordEnd;
	}

	public void setRecordEnd(int recordEnd) {
		this.recordEnd = recordEnd;
	}

	public int getRecordTotal() {
		return recordTotal;
	}

	public void setRecordTotal(int recordTotal) {
		this.recordTotal = recordTotal;
	}

	public Date getTimeStart() {
		return timeStart;
	}

	public void setTimeStart(Date timeStart) {
		this.timeStart = timeStart;
	}

	public Date getTimeEnd() {
		return timeEnd;
	}

	public void setTimeEnd(Date timeEnd) {
		this.timeEnd = timeEnd;
	}
}
